﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text;
            string weekDay;

            // 用switch判断输入的字符串（避免类型转换错误，也可先转int）
            switch (input)
            {
                case "1":
                    weekDay = "Monday";
                    break;
                case "2":
                    weekDay = "Tuesday";
                    break;
                case "3":
                    weekDay = "Wednesday";
                    break;
                case "4":
                    weekDay = "Thursday";
                    break;
                case "5":
                    weekDay = "Friday";
                    break;
                case "6":
                    weekDay = "Saturday";
                    break;
                case "7":
                    weekDay = "Sunday";
                    break;
                default:
                    // 输入不合法，弹出提示框
                    MessageBox.Show("请输入数字1-7！", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    weekDay = ""; // 清空结果
                    textBox1.Text = ""; // 清空输入框
                    textBox1.Focus(); // 光标回到输入框
                    break;
            }

            // 显示结果（合法输入时）
            textBox2.Text = weekDay;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 清空输入数字的文本框（textBox1）内容
            textBox1.Text = "";
            // 清空显示星期结果的只读文本框（textBox2）内容
            textBox2.Text = "";
            // （可选）将光标聚焦回输入文本框，方便用户直接再次输入
            textBox1.Focus();
        }
    }
}
